@extends("/paging_template",title="区域列表")
@import com.mgfireworks.mgplatform.mgadmin.sys.model.Area
@import com.mgfireworks.mgplatform.mgadmin.constants.AreaLevel
@import cn.hn.java.summer.utils.JsonUtils
@args List<Area> areaList
<s_panel>
	<s_input name="areaName" text="区域名称"></s_input>
	<s_select name="areaLevel" text="区域级别" value="@val("areaLevel")">
	@for(AreaLevel level : AreaLevel.values()){
		<option value="@level.value()">@level.getPhrase()</option>
	}
	</s_select>
	<s_input name="parentArea" text="父级名称"></s_input>
	<s_buttons slot="button" cols="4">
		<s_button type="query"></s_button>
		<s_button type="link" icon="fa-plus" href="@url("add.html")">添加</s_button>
		<s_button type="link" icon="fa-pencil" href="@url("edit.html?areaId={0}")">修改</s_button>
		<s_button type="del" href="@url("del.json?areaId={0}")">删除</s_button>
	</s_buttons>
</s_panel>

<div id="jsTreeView">
</div>

@section(script){
<script type="text/javascript">
    $(function(){
//		$.getJSON("@url("/static/test1.json")",function(data){
//			//生成区域树数据
//			var areaTree=util.el.genNoDelayTree({
//				data:data,
//				rootText:"权限分配",
//				rootValue:"0",
//				dataParentId:"parentId",
//				dataTextName:"areaName",
//				dataValueName:"areaId",
//				showStyle:"noDelay"
//			});
//			console.log(areaTree);
//			$("#jsTreeView").treenomal({
//				text: "text",
//				value: "value",
//				depth: 3,
//				textName: "areaName",
//				valueName: "areaId",
//				selectedValue: "001",
//				data: areaTree
//			});
//		});
		var areaList=JSON.parse('@JsonUtils.toJson(areaList)');
        //生成区域树数据
        var areaTree=util.el.genTreeData({
            data:areaList,
            rootText:"中国",
            rootValue:"0",
            dataParentId:"parentId",
            dataTextName:"areaName",
            dataValueName:"areaId"
        });
        $("#jsTreeView").treeview({
            text: "text",
            value: "value",
            depth: 2,
			textName: "areaName",
			valueName: "areaId",
			selectedValue: "001",
			remote: "list.json?parentId={0}",
            data: areaTree
        });

    });
</script>
}